Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow network requests in instances of the CurrencyRate and TokenRate controllers to be disabled #1002

Merged
merged 16 commits into from
Dec 6, 2022

Conversation

NiranjanaBinoy
Copy link
Contributor

@NiranjanaBinoy NiranjanaBinoy commented Dec 2, 2022

Allow network requests in instances of the CurrencyRate and TokenRate controllers to be disabled

Description

  • BREAKING:

    • A new private property is added to the CurrencyRateController: enabled. If this is false, then the function in that controller which makes network requests will not make any requests when called. This property is controlled by the start and stop methods, so that these methods will effectively enable or disable network requests. Previously, even if stop had been called, setNativeCurrency or setCurrentCurrency would trigger a network request. That is now prevented.
  • FIXED:

    • The TokenRatesController previously had a bug whereby if a disabled property was passed to the constructive as part of the config object, it would be ignored / overwritten to false. This PR fixes that.

Checklist

  • Tests are included if applicable
  • Any added code is fully documented

Issue
Part of #16724

@NiranjanaBinoy NiranjanaBinoy requested a review from a team as a code owner December 2, 2022 01:20
@NiranjanaBinoy NiranjanaBinoy self-assigned this Dec 2, 2022
@NiranjanaBinoy NiranjanaBinoy requested a review from danjm December 2, 2022 01:20
@NiranjanaBinoy NiranjanaBinoy marked this pull request as draft December 2, 2022 02:35
@NiranjanaBinoy NiranjanaBinoy marked this pull request as ready for review December 2, 2022 02:35
@danjm
Copy link
Contributor

danjm commented Dec 2, 2022

I think that with these modifications to this the extension PR, we can greatly simplify the changes in this controllers PR: https://github.com/MetaMask/metamask-extension/compare/optional-currency-conversion...optional-currency-conversion-alt?expand=1

I believe that we can simplify this PR to: https://github.com/MetaMask/controllers/compare/allow-disabled-config-tokenratescontroller?expand=1

@danjm
Copy link
Contributor

danjm commented Dec 2, 2022

This PR is now ready for review

@danjm danjm changed the title Toggle option to enable/disable balance and Token rate checking for using third-party API Allow network requests in instances of the CurrencyRate and TokenRate controllers to be disabled Dec 2, 2022
danjm and others added 3 commits December 2, 2022 20:53
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple more.

mcmire
mcmire previously approved these changes Dec 5, 2022
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple more suggestions but overall I'm good with this PR.

danjm and others added 2 commits December 5, 2022 16:23
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
@danjm
Copy link
Contributor

danjm commented Dec 6, 2022

This PR is the same as it was when Elliot previously approved, except that two code comments suggested by Elliot have since been added.

@danjm danjm merged commit d24c57a into main Dec 6, 2022
@danjm danjm deleted the optin-rate-checking branch December 6, 2022 10:37
@pedronfigueiredo pedronfigueiredo self-assigned this Dec 8, 2022
gantunesr pushed a commit that referenced this pull request Dec 8, 2022
… controllers to be disabled (#1002)

**Allow network requests in instances of the CurrencyRate and TokenRate
controllers to be disabled**

**Description**

- BREAKING:
- A new private property is added to the CurrencyRateController:
`enabled`. If this is false, then the function in that controller which
makes network requests will not make any requests when called. This
property is controlled by the `start` and `stop` methods, so that these
methods will effectively enable or disable network requests. Previously,
even if `stop` had been called, `setNativeCurrency` or
`setCurrentCurrency` would trigger a network request. That is now
prevented.

- FIXED:
- The TokenRatesController previously had a bug whereby if a `disabled`
property was passed to the constructive as part of the `config` object,
it would be ignored / overwritten to false. This PR fixes that.


**Checklist**

- [ ] Tests are included if applicable
- [ ] Any added code is fully documented

**Issue**
Part of
[#16724](MetaMask/metamask-extension#16724)

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Pedro Figueiredo <pedro.figueiredo@consensys.net>
Co-authored-by: Pedro Figueiredo <ganseki.figueiredo@gmail.com>
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
… controllers to be disabled (#1002)

**Allow network requests in instances of the CurrencyRate and TokenRate
controllers to be disabled**

**Description**

- BREAKING:
- A new private property is added to the CurrencyRateController:
`enabled`. If this is false, then the function in that controller which
makes network requests will not make any requests when called. This
property is controlled by the `start` and `stop` methods, so that these
methods will effectively enable or disable network requests. Previously,
even if `stop` had been called, `setNativeCurrency` or
`setCurrentCurrency` would trigger a network request. That is now
prevented.

- FIXED:
- The TokenRatesController previously had a bug whereby if a `disabled`
property was passed to the constructive as part of the `config` object,
it would be ignored / overwritten to false. This PR fixes that.


**Checklist**

- [ ] Tests are included if applicable
- [ ] Any added code is fully documented

**Issue**
Part of
[#16724](MetaMask/metamask-extension#16724)

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Pedro Figueiredo <pedro.figueiredo@consensys.net>
Co-authored-by: Pedro Figueiredo <ganseki.figueiredo@gmail.com>
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
… controllers to be disabled (#1002)

**Allow network requests in instances of the CurrencyRate and TokenRate
controllers to be disabled**

**Description**

- BREAKING:
- A new private property is added to the CurrencyRateController:
`enabled`. If this is false, then the function in that controller which
makes network requests will not make any requests when called. This
property is controlled by the `start` and `stop` methods, so that these
methods will effectively enable or disable network requests. Previously,
even if `stop` had been called, `setNativeCurrency` or
`setCurrentCurrency` would trigger a network request. That is now
prevented.

- FIXED:
- The TokenRatesController previously had a bug whereby if a `disabled`
property was passed to the constructive as part of the `config` object,
it would be ignored / overwritten to false. This PR fixes that.


**Checklist**

- [ ] Tests are included if applicable
- [ ] Any added code is fully documented

**Issue**
Part of
[#16724](MetaMask/metamask-extension#16724)

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Pedro Figueiredo <pedro.figueiredo@consensys.net>
Co-authored-by: Pedro Figueiredo <ganseki.figueiredo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants